package com.gmrz.uap.job;

import com.gmrz.uap.cfg.SystemConst;
import com.gmrz.uap.common.DbConst;
import org.joda.time.DateTime;

import java.util.ArrayList;
import java.util.List;

public class TaskConst {

    public final static String STATISTICS_KEY_REGCOUNT = "regCount";//注册数量
    public final static String STATISTICS_KEY_REGCOMPARECOUNT = "regCompareCount";//注册环比
    public final static String STATISTICS_KEY_LOGOUTCOUNT = "logoutCount";//注销数量
    public final static String STATISTICS_KEY_LOGOUTCOMPARECOUNT = "logoutCompareCount";//注销环比
    public final static String STATISTICS_KEY_VERIFY = "verify";//验证
    public final static String STATISTICS_KEY_AAID = "aaid";//认证器
    public final static String STATISTICS_KEY_TRANS_TYPE = "transType";//交易类型
    public final static String STATISTICS_KEY_DEVICE_TYPE = "deviceType";//设备厂商
    public final static String STATISTICS_KEY_OS_TYPE = "osType";//系统类型
    public final static String STATISTICS_KEY_OPER_TYPE = "operType";//操作类型
    public final static String STATISTICS_KEY_CERT_DEVICE_TYPE = "certDeviceType";//证书设备厂商
    public final static String STATISTICS_KEY_CERT_USE_CASE = "certUseCase";// 证书使用情况

    public static final String AAIDSTATISTICSDAYJOB_CACHE_KEY = "uaf.aaidstatisticsdayjob.cache.key.";
    public static final String CERTDEVICETYPESTATISTICSDAYJOB_CACHE_KEY = "uaf.certdevicetypestatisticsdayjob.cache.key.";
    public static final String DELETEFIDOLOGJOB_CACHE_KEY = "uaf.deletefidologjob.cache.key.";
    public static final String DEVICETYPESTATISTICSDAYJOB_CACHE_KEY = "uaf.devicetypestatisticsdayjob.cache.key.";
    public static final String LOGOUTSTATISTICSDAYJOB_CACHE_KEY = "uaf.logoutstatisticsdayjob.cache.key.";
    public static final String OSTYPESTATISTICSDAYJOB_CACHE_KEY = "uaf.ostypestatisticsdayjob.cache.key.";
    public static final String REGISTERSTATISTICSDAYJOB_CACHE_KEY = "uaf.registerstatisticsdayjob.cache.key.";
    public static final String TRANSTYPESTATISTICSDAYJOB_CACHE_KEY = "uaf.transtypestatisticsdayjob.cache.key.";
    public static final String UPDATEUSERSTATUSDAYJOB_CACHE_KEY = "uaf.updateuserstatusdayjob.cache.key.";
    public static final String VERIFYSTATISTICSDAYJOB_CACHE_KEY = "uaf.verifystatisticsdayjob.cache.key.";
    public static final String CERTUSESTATISTICSDAYJOB_CACHE_KEY = "uaf.certusestatisticsdayjob.cache.key.";

    public static final String JOB_CACHE_VALUE = "jobcachevalue";
    public static final int AAIDSTATISTICSDAYJOB_CACHE_TiME = 24 * 60 * 60 * 1000;
    /**
     * 获取需要统计分析的年份和月份
     *
     * @return
     */
    public static int[] getStatisticsYearAndMonth() {
        int[] statisticsDate = new int[6];
        DateTime currDate = new DateTime();
        DateTime prevDate = currDate.minusMonths(1);
        DateTime befDate = currDate.minusMonths(2);


        statisticsDate[0] = currDate.getYear();
        statisticsDate[1] = currDate.getMonthOfYear();
        statisticsDate[2] = prevDate.getYear();
        statisticsDate[3] = prevDate.getMonthOfYear();
        statisticsDate[4] = befDate.getYear();
        statisticsDate[5] = befDate.getMonthOfYear();

        return statisticsDate;
    }

    /**
     * 获取需要统计分析的日期
     *
     * @return
     */
    public static String[] getStatisticsDate() {
        String[] statisticsDateArr = new String[3];
        DateTime currDate = new DateTime();
        DateTime prevDate = currDate.minusMonths(1);
        DateTime befDate = currDate.minusMonths(2);

        statisticsDateArr[0] = currDate.toString(SystemConst.DEFAULT_DATE_FOMATTER_YEARMONTH);
        statisticsDateArr[1] = prevDate.toString(SystemConst.DEFAULT_DATE_FOMATTER_YEARMONTH);
        statisticsDateArr[2] = befDate.toString(SystemConst.DEFAULT_DATE_FOMATTER_YEARMONTH);

        return statisticsDateArr;
    }


    /**
     * 根据数据转换成对应的英文字段信息
     *
     * @param num
     * @return
     */
    public static String convertNumToMonth(int num) {
        String month = null;
        if (num == 1) {
            month = "jan_total";
        } else if (num == 2) {
            month = "feb_total";
        } else if (num == 3) {
            month = "mar_total";
        } else if (num == 4) {
            month = "apr_total";
        } else if (num == 5) {
            month = "may_total";
        } else if (num == 6) {
            month = "jun_total";
        } else if (num == 7) {
            month = "jul_total";
        } else if (num == 8) {
            month = "aug_total";
        } else if (num == 9) {
            month = "sep_total";
        } else if (num == 10) {
            month = "oct_total";
        } else if (num == 11) {
            month = "nov_total";
        } else if (num == 12) {
            month = "dec_total";
        }

        return month;
    }

    public static void main(String[] args) {
        int[] staArr = getStatisticsYearAndMonth();
        for (int num : staArr) {
            System.out.println(num);
        }


        String[] getStatisticsDate = getStatisticsDate();
        for (String date : getStatisticsDate) {
            System.out.println(date);
        }
    }

}
